﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverlightApplication1.GdiService;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace SilverlightApplication1
{
    public class HomeViewModel : BaseViewModel
    {
        GdiStoryServiceClient _client = new GdiStoryServiceClient();
        public HomeViewModel()
        {
            _client.GetStoriesCompleted += new EventHandler<GetStoriesCompletedEventArgs>(_client_GetStoriesCompleted);
            if (DesignerProperties.IsInDesignTool)
            {

            }
            else
            {
                _client.GetStoriesAsync();
            }
        }

        void _client_GetStoriesCompleted(object sender, GetStoriesCompletedEventArgs e)
        {
            Stories = e.Result;
            
        }

        private ObservableCollection<Story> _stories = new ObservableCollection<Story>();
        public ObservableCollection<Story> Stories
        {
            get
            {
                return _stories;
            }
            set
            {
                _stories = value;
                RaisePropertyChanged("Stories");
            }
        }
    }
}
